/**
 * @param {number[]} nums
 * @param {number} val
 * @return {number}
 */
var removeElement = function (nums, val) {
  // 先排序，后删除
  const len = nums.length
  for (let i = 0; i < len - 1; i++) {
    for (let j = 0; j < len - 1 - i; j++) {
      if (nums[j] > nums[j + 1]) {
        const tmp = nums[j]
        nums[j] = nums[j + 1]
        nums[j + 1] = tmp
      }
    }
  }
  for (var index = 0; nums[index] != val && index < nums.length; index++) {
  }

  for (var count = index; nums[count] == val && count < nums.length; count++) {

  }
  nums.splice(index, count - index)
  return nums.length
};

console.log(removeElement([0], 2))